from mods.entities.handlers import EntityRegistryHandler, SpriteRegistryHandler, PlaceObstacle, PlaceRegeneration
from mods.entities.test import Shoot, ShootRocket
from src.keyboard.ability import AbilitySwitchHandler, AbilityCastHandler
from src.handler.keyboard import KeyboardHandler
from src.handler.mouse import MouseHandler
from src.handler.event import EventHandler
from src.config.events import *
import pygame

def init(client):
    print("entities initialised")

    
    KeyboardHandler.register(pygame.K_1, ShootRocket())
    KeyboardHandler.register(pygame.K_f, PlaceObstacle())
    KeyboardHandler.register(pygame.K_h, PlaceRegeneration())
    EventHandler.subscripe(WORLD_ENTITY_REGISTRY, EntityRegistryHandler())
    EventHandler.subscripe(SPRITEHANDLER_REGISTRY, SpriteRegistryHandler())
    EventHandler.subscripe(WORLD_LOAD, WorldLoadHandler())

class WorldLoadHandler():
    
    def handle(self, event):
        MouseHandler.register(4, AbilitySwitchHandler(event.world.player))
        MouseHandler.register(5, AbilitySwitchHandler(event.world.player))
        MouseHandler.register(1, AbilityCastHandler(event.world.player))

